# -*- encoding: utf-8 -*-
import os
import cv2


def img2video(img_storage, target_video, save_fourcc_format='mp4v'):
    f_width = 1920
    f_height = 1080
    f_shape = (int(f_width), int(f_height))
    fps = int(25)
    four_cc = cv2.VideoWriter_fourcc(*save_fourcc_format)
    video_writer = cv2.VideoWriter(target_video, four_cc, fps, f_shape)
    image_list = os.listdir(img_storage)
    image_list.sort()
    frame_count = 0
    print()
    for image_name in image_list:
        frame_count += 1
        image_path = os.path.join(img_storage, image_name)
        print(image_path)
    #     print(f"Processing {image_path}, {frame_count} / {len(image_list)}")
    #     frame_tem = cv2.imread(image_path)
    #     video_writer.write(frame_tem)
    # video_writer.release()


if __name__ == "__main__":
    image_storage_path = r"/home/stark/algo-env/yolov7-MGN/data/video_fragment/pictures"
    target_video_path = r"/home/stark/algo-env/yolov7-MGN/data/video_fragment/sample-screen.mp4"
    img2video(image_storage_path, target_video_path)

